package servlet.gc;

import pojo.Grade;
import pojo.Student;
import service.GradeServiceImpl;
import service.GradeService;
import service.StudentService;
import service.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(urlPatterns = ("/toUpdateStudent"))
public class toUpdateStudentServlet extends HttpServlet {
    StudentService studentService = new StudentServiceImpl();
    GradeService gradeService = new GradeServiceImpl();
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String stuId = req.getParameter("stuId");
        Student student = studentService.selectById(Integer.parseInt(stuId));
        req.setAttribute("stu",student);
        List<Grade> list = gradeService.selectALl();
        req.setAttribute("gradeList",list);
        req.getRequestDispatcher("/Educational/student/edit.jsp").forward(req,resp);
    }
}
